package liuyuyang.controller;

import liuyuyang.domain.Classes;
import liuyuyang.pojo.Result;
import liuyuyang.service.ClassesService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/class")
public class ClassesController {
    @Resource
    private ClassesService classesService;

    @GetMapping("/{id}")
    public Result<Classes> get(@PathVariable Integer id){
        return Result.success(classesService.getById(id));
    }

    @GetMapping
    public Result<List<Classes>> list(){
        return Result.success(classesService.list());
    }
}
